﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpawnMover : MonoBehaviour
{
    //分数
    public int grade = 10;
    //间隔时间
    public float lastFall;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        //控制方块的移动
        //按下左键
        if(Input.GetKeyDown(KeyCode.LeftArrow)){
            this.gameObject.transform.position += new Vector3(-1,0,0);
        }
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            this.gameObject.transform.position += new Vector3(1, 0, 0);
        }
        //按下UP键后，旋转90度
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            this.gameObject.transform.Rotate(0,0,90);
        }
        //按下DOWN键后，下落
        //每秒钟也下落
        if (Input.GetKeyDown(KeyCode.DownArrow) || Time.time - lastFall >1)
        {
            this.gameObject.transform.position += new Vector3(0, -1, 0) *1;
            lastFall = Time.time;
        }


    }

    bool isValidGridPos() {
        foreach (Transform child in transform) {
            //找不到这个方法。
            Vector2 v = Grid.roundVec2(child.position);
        }

        return true;
    }
}
